package com.thinkingcoder.tcregistry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.thinkingcoder.tcregistry.cluster.Cluster;
import com.thinkingcoder.tcregistry.health.HealthChecker;
import com.thinkingcoder.tcregistry.health.TcHealthChecker;
import com.thinkingcoder.tcregistry.service.RegistryService;
import com.thinkingcoder.tcregistry.service.TcRegistryService;

/**
 * Configuration for all beans.
 */
@Configuration
public class TcRegistryConfig {

    @Bean(initMethod = "start", destroyMethod = "stop")
    HealthChecker healthChecker(@Autowired RegistryService registryService) {
        return new TcHealthChecker(registryService);
    }

    @Bean(initMethod = "init")
    public Cluster cluster(@Autowired TcRegistryConfigProperties registryConfigProperties) {
        return new Cluster(registryConfigProperties);
    }

    @Bean
    RegistryService registryService() {
        return new TcRegistryService();
    }

}
